﻿Public Class Form1
  Private Sub Button1_Click(ByVal sender _
        As System.Object, _
        ByVal e As System.EventArgs) _
        Handles Button1.Click
    Dim NL As String = Environment.NewLine
    Dim tortaBrucia As Boolean = False
    ' ... eventuale modifica del valore
    ' di tortaBrucia ...
    Try
      If tortaBrucia Then
        Throw New  _
           System.Exception("" & _
              "Controlla il forno: " & _
              "sta bruciando la torta!")
      Else
        Throw New MyException
      End If
    Catch ex As MyException
      MessageBox.Show("Eccezione " & _
         "personalizzata")
    Catch ex As Exception
      MessageBox.Show("ALLARME" & _
         NL & NL & ex.Message & _
         NL & NL & ex.StackTrace)
    End Try
  End Sub
End Class
